#define ENABLE_ROOT_EXCEPTION_HANDLING
using System;
using System.Windows.Forms;
using dpatoolkit;
using dpatoolkit.UILayer;
using dpatoolkit.Extensions;

namespace dpatoolkit
{
	public class MainClass
	{
		[STAThread]
		static void Main(string[] args) 
		{
			DPAToolkitMainForm dpa_app =  null;
#if ENABLE_ROOT_EXCEPTION_HANDLING
            try
            {
#endif //ENABLE_ROOT_EXCEPTION_HANDLING
                
                /* TODO : Load the settings */

                /* Scan for extensions */
                //DPAExtensions.ScanForExtensions(dpatoolkit.GlobalSettings.DefaultReverseEngineeringPlugin);
                //DPAExtensions.ScanForExtensions(dpatoolkit.GlobalSettings.DefaultCodeGenerationPlugin);

                dpa_app = new DPAToolkitMainForm();

				Application.Run(dpa_app);

#if ENABLE_ROOT_EXCEPTION_HANDLING
            }
            catch (Exception e)
            {
                ExceptionForm form = new ExceptionForm(e);
                form.ShowDialog();
                MessageBox.Show("Since the application was closed because of exception, it will try to recover all open projects and plugins");
                dpa_app.SaveAll(true);
            }
#endif //ENABLE_ROOT_EXCEPTION_HANDLING
        }
	}
}
